using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL
{

    /// <summary>
    /// The StudentGuardianRelationshipTableManager class is responsible for managing BO.StudentGuardianRelationshipTable objects in the system.
    /// </summary>
    [DataObjectAttribute()]
    public class StudentGuardianRelationshipTableManager
    {

        #region "Public Methods"

        /// <summary>
        /// Gets a list with all StudentGuardianRelationshipTable objects in the database.
        /// </summary>
        /// <returns>A list with all StudentGuardianRelationshipTable from the database when the database contains any, or null otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static StudentGuardianRelationshipTableList GetList()
        {
            return StudentGuardianRelationshipTableDB.GetList();
        }

        /// <summary>
        /// Gets a single StudentGuardianRelationshipTable from the database without its data.
        /// </summary>
        /// <param name="guardianAccountKey">The GuardianAccountKey of the StudentGuardianRelationshipTable in the database.</param>
        /// <returns>A StudentGuardianRelationshipTable object when the GuardianAccountKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentGuardianRelationshipTable GetItem(int gsAutoID)
        {
            return GetItem(gsAutoID, false);
        }

        /// <summary>
        /// Gets a single StudentGuardianRelationshipTable from the database without its data.
        /// </summary>
        /// <param name="guardianAccountKey">The GuardianAccountKey of the StudentGuardianRelationshipTable in the database.</param>
        /// <returns>A StudentGuardianRelationshipTable object when the GuardianAccountKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentGuardianRelationshipTable GetItemByGuardianAccountKey(int GuardianAccountKey)
        {
            StudentGuardianRelationshipTable myStudentGuardianRelationshipTable = StudentGuardianRelationshipTableDB.GetItemByGuardianAccountKey(GuardianAccountKey);
            return myStudentGuardianRelationshipTable;
        }

        /// <summary>
        /// Gets a single StudentGuardianRelationshipTable from the database without its data.
        /// </summary>
        /// <param name="guardianAccountKey">The GuardianAccountKey of the StudentGuardianRelationshipTable in the database.</param>
        /// <returns>A StudentGuardianRelationshipTable object when the GuardianAccountKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentGuardianRelationshipTable GetItemByGuardianAccountKey(int GuardianAccountKey, bool OnlyMainGuardian)
        {
            StudentGuardianRelationshipTable myStudentGuardianRelationshipTable = StudentGuardianRelationshipTableDB.GetItemByGuardianAccountKey(GuardianAccountKey, OnlyMainGuardian);
            return myStudentGuardianRelationshipTable;
        }


        /// <summary>
        /// Gets a single StudentGuardianRelationshipTable from the database without its data.
        /// </summary>
        /// <param name="guardianAccountKey">The GuardianAccountKey of the StudentGuardianRelationshipTable in the database.</param>
        /// <returns>A StudentGuardianRelationshipTable object when the GuardianAccountKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentGuardianRelationshipTable GetItemByStudentAccountKey(int StudentAccountKey, bool OnlyMainGuardian)
        {
            StudentGuardianRelationshipTable myStudentGuardianRelationshipTable = StudentGuardianRelationshipTableDB.GetItemByStudentAccountKey(StudentAccountKey, OnlyMainGuardian);
            return myStudentGuardianRelationshipTable;
        }

        /// <summary>
        /// Gets a single StudentGuardianRelationshipTable from the database without its data.
        /// </summary>
        /// <param name="guardianAccountKey">The GuardianAccountKey of the StudentGuardianRelationshipTable in the database.</param>
        /// <returns>A StudentGuardianRelationshipTable object when the GuardianAccountKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentGuardianRelationshipTable GetItemByStudentAccountKey(int StudentAccountKey)
        {
            StudentGuardianRelationshipTable myStudentGuardianRelationshipTable = StudentGuardianRelationshipTableDB.GetItemByStudentAccountKey(StudentAccountKey);
            return myStudentGuardianRelationshipTable;
        }
        /// <summary>
        /// Gets a single StudentGuardianRelationshipTable from the database.
        /// </summary>
        /// <param name="guardianAccountKey">The GuardianAccountKey of the StudentGuardianRelationshipTable in the database.</param>
        /// <param name="getStudentGuardianRelationshipTableRecords">Determines whether to load all associated StudentGuardianRelationshipTable records as well.</param>
        /// <returns>
        /// A StudentGuardianRelationshipTable object when the GuardianAccountKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentGuardianRelationshipTable GetItem(int gsAutoID, bool getStudentGuardianRelationshipTableRecords)
        {
            StudentGuardianRelationshipTable myStudentGuardianRelationshipTable = StudentGuardianRelationshipTableDB.GetItem(gsAutoID);
            return myStudentGuardianRelationshipTable;
        }

        /// <summary>
        /// Saves a StudentGuardianRelationshipTable in the database.
        /// </summary>
        /// <param name="myStudentGuardianRelationshipTable">The StudentGuardianRelationshipTable instance to save.</param>
        /// <returns>The new GuardianAccountKey if the StudentGuardianRelationshipTable is new in the database or the existing GuardianAccountKey when an item was updated.</returns>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static int Save(StudentGuardianRelationshipTable myStudentGuardianRelationshipTable)
        {
            using (TransactionScope myTransactionScope = new TransactionScope())
            {
                int gsAutoID = StudentGuardianRelationshipTableDB.Save(myStudentGuardianRelationshipTable);

                //  Assign the StudentGuardianRelationshipTable its new (or existing GuardianAccountKey).
                myStudentGuardianRelationshipTable.GSAutoID = gsAutoID;

                myTransactionScope.Complete();

                return gsAutoID;
            }
        }

        /// <summary>
        /// Deletes a StudentGuardianRelationshipTable from the database.
        /// </summary>
        /// <param name="myStudentGuardianRelationshipTable">The StudentGuardianRelationshipTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(StudentGuardianRelationshipTable myStudentGuardianRelationshipTable)
        {
            return StudentGuardianRelationshipTableDB.Delete(myStudentGuardianRelationshipTable.GuardianAccountKey);
        }

        #endregion

    }

}
